package sdmakerz_v1.coresyntax.generator;

import com.google.common.base.Objects;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import sdmakerz_v1.coresyntax.SDMakerV1Utils;
import sdmakerz_v1.coresyntax.generator.interfaces.IInputData;
import sdmakerz_v1.coresyntax.generator.interfaces.IMethodData;
import sdmakerz_v1.coresyntax.sDMakerV1.Call;
import sdmakerz_v1.coresyntax.sDMakerV1.Expression;

@SuppressWarnings("all")
public class MethodDataImpl implements IMethodData {
  private String methodName;
  
  private List<Call> calls;
  
  private List<String> paramsRealType;
  
  /**
   * ** INITIALIZERS **
   */
  public void init(final IInputData inputData, final Call model) {
    ArrayList<Call> _arrayList = new ArrayList<Call>();
    this.calls = _arrayList;
    ArrayList<String> _arrayList_1 = new ArrayList<String>();
    this.paramsRealType = _arrayList_1;
    EList<Expression> _params = model.getParams();
    for (final Expression exp : _params) {
      String _clazzQualifiedNameFromExp = SDMakerV1Utils.clazzQualifiedNameFromExp(inputData, exp);
      this.paramsRealType.add(_clazzQualifiedNameFromExp);
    }
    String _name = model.getName();
    this.methodName = _name;
  }
  
  /**
   * ** SETTERS **
   */
  public void addCall(final IInputData inputData, final Call c) {
    this.calls.add(c);
  }
  
  public void setTypeOwner(final String typeOwner) {
    this.setTypeOwner(typeOwner);
  }
  
  public void setName(final String name) {
    this.setName(name);
  }
  
  /**
   * ** GETTERS **
   */
  public String getMethodName() {
    return this.methodName;
  }
  
  public List<String> getParamsRealType() {
    return this.paramsRealType;
  }
  
  public String getParamType(final int i) {
    return this.paramsRealType.get(i);
  }
  
  public List<Call> getCalls() {
    return this.calls;
  }
  
  /**
   * ** TESTORS **
   */
  public boolean match(final IInputData inputData, final Call c) {
    int i = 0;
    boolean goodPreconditions = true;
    boolean match = true;
    String _name = c.getName();
    int _compareTo = _name.compareTo(this.methodName);
    boolean _notEquals = (_compareTo != 0);
    if (_notEquals) {
      goodPreconditions = false;
    }
    EList<Expression> _params = c.getParams();
    int _size = _params.size();
    int _size_1 = this.paramsRealType.size();
    boolean _notEquals_1 = (_size != _size_1);
    if (_notEquals_1) {
      goodPreconditions = false;
    }
    if (goodPreconditions) {
      EList<Expression> _params_1 = c.getParams();
      for (final Expression exp : _params_1) {
        {
          String _get = this.paramsRealType.get(i);
          String _clazzQualifiedNameFromExp = SDMakerV1Utils.clazzQualifiedNameFromExp(inputData, exp);
          int _compareTo_1 = _get.compareTo(_clazzQualifiedNameFromExp);
          boolean _equals = Objects.equal(Integer.valueOf(_compareTo_1), Boolean.valueOf(false));
          if (_equals) {
            match = false;
          }
          int _plus = (i + 1);
          i = _plus;
        }
      }
    } else {
      match = false;
    }
    return match;
  }
}
